Create database QLTC
go
use QLTC
go
create table NguoiDung
(
	IDNguoiDung int  IDENTITY(1,1) NOT NULL,
	Ten nvarchar(50), 
	Pass nvarchar(20), 
	Quyen nvarchar (20), 
	
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[IDNguoiDung] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

go
create table Thu
(
	IDThu int  IDENTITY(1,1) NOT NULL,
	NoiDungThu nvarchar (max) ,
	SoTienThu int ,
	MaPhaLoaiThu int, 
	MaNguoiThu int ,
	NgayThu date ,
	MaNH int, 
	MaNguoiTao int,
	CONSTRAINT [PK_Thu] PRIMARY KEY CLUSTERED 
(
	[IDThu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

go
CREATE TABLE  PhanLoaiThu(
	IDPhanLoaiThu int IDENTITY(1,1) NOT NULL,
	TenPLThu nvarchar(50) ,
	
 CONSTRAINT [PK_PhanLoaiThu] PRIMARY KEY CLUSTERED 
(
	[IDPhanLoaiThu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
CREATE TABLE  Chi (

	IDChi int IDENTITY(1,1) NOT NULL,
	NoiDungChi nvarchar(max) ,
	SoTienChi int ,
	MaPhanLoaiChi int,
	MaNguoiChi int,
	NgayChi date ,
	MaNH int, 
	MaNguoiTao int,
	
 CONSTRAINT [PK_Chi] PRIMARY KEY CLUSTERED 
(
	[IDChi] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE  PhanLoaiChi(
	IDPLChi int IDENTITY(1,1) NOT NULL,
	TenPLChi nvarchar(50) ,
 CONSTRAINT [PK_PhanLoaiChi] PRIMARY KEY CLUSTERED 
(
	[IDPLChi] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table ThuCoDinh
(
	IDThuCD int  IDENTITY(1,1) NOT NULL,
	NoiDungThu nvarchar (max) ,
	SoTienThu int ,
	MaPhaLoaiThu int, 
	MaNguoiThu int ,
	Ngay int,
	MaNH int, 
	MaNguoiTao int,
	Thang date,
	CONSTRAINT [PK_ThuCD] PRIMARY KEY CLUSTERED 
(
	[IDThuCD] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
create table ChiCD
(
	IDChiCD int IDENTITY(1,1) NOT NULL,
	NoiDungChi nvarchar(max) ,
	SoTienChi int ,
	MaPhanLoaiChi int,
	MaNguoiChi int,
	Ngay int ,
	MaNH int, 
	MaNguoiTao int,
	Thang date,
	CONSTRAINT [PK_ChiCD] PRIMARY KEY CLUSTERED 
(
	[IDChiCD] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table NganHang
(
	IDNganHang int IDENTITY(1,1) NOT NULL,
	Ten nvarchar(50) ,
	IDNguoiDung int ,
	TrangThai int,
	CONSTRAINT [PK_NganHang] PRIMARY KEY CLUSTERED 
(
	[IDNganHang] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table ChuyenKhoan
(
	IDChuyenKhoan int IDENTITY(1,1) NOT NULL,
	IDChuyen int,
	IDNhan int,
	Sotien int,
	
	CONSTRAINT [PK_ChuyenKhoan] PRIMARY KEY CLUSTERED 
(
	[IDChuyenKhoan] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table TinDung
(
	IDTinDung int IDENTITY(1,1) NOT NULL,
	HanMuc nvarchar (20),
	NgayLap date,
	LaiXuat int,
	
	CONSTRAINT [PK_TinDung] PRIMARY KEY CLUSTERED 
(
	[IDTinDung] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

create table ChiTieTTD
(
	IDChiTietTD int IDENTITY(1,1) NOT NULL,
	IDTinDung int,
	Ngay date,
	SoTien int,
	NoiDung nvarchar (50),
	
	CONSTRAINT [PK_ChiTietTD] PRIMARY KEY CLUSTERED 
(
	[IDChiTietTD] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

create table TKNo
(
	IDTKNo int IDENTITY(1,1) NOT NULL,
	Ten nchar (50),
	SoTien int,
	NoiDung nvarchar (50),
	
	CONSTRAINT [PK_TKNo] PRIMARY KEY CLUSTERED 
(
	[IDTKNo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

create table ChiTietTKNo
(
	IDChiTietTKNo int IDENTITY(1,1) NOT NULL,
	IDTKNo int,
	Ten nchar (50),
	SoTien int,
	NoiDung nvarchar (50),
	
	CONSTRAINT [PK_ChiTietTKNo] PRIMARY KEY CLUSTERED 
(
	[IDChiTietTKNo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table TietKiem
(
	IDTietKiem int IDENTITY(1,1) NOT NULL,
	Ngay date,
	LaiXuat int,
	KyHan int, 
	NoiDung nvarchar (50),
	IDNganHang int,
	TuGiaHan int, 
	
	CONSTRAINT [PK_TietKiem] PRIMARY KEY CLUSTERED 
(
	[IDTietKiem] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
create table CTTraTinDung
(
	IDTraTD int IDENTITY(1,1) NOT NULL,
	IDTinDung int, 
	SoTien int,
	Ngay date, 
	DaThanhToan nchar (20),
	ChuaThanhToan nchar (20),
	IDNguoiDung int,
	
	CONSTRAINT [PK_CTTraTinDung] PRIMARY KEY CLUSTERED 
(
	[IDTraTD] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO